<template>
  <div class="yizhou" style="padding-top: 20px;">
    <div id="main" style="width: 660px; height:380px;"></div>
  </div>
</template>

<script>
  import * as echarts from 'echarts';
	export default {
		name: 'yizhou',
		data() {
			return {
        log2:true,
        month:moment().format('YYYY-MM'),
        type:1,
        list2:"",

        yizhou:{
          count:"",
          data:"",
          time:""
        }
			}
		},
		created() {
      this.getlist2()
		},
		mounted() {

		},
		methods: {
      qushitu:function(){
        var myChart = echarts.init(document.getElementById('main'));
        let x = []
        let y = [
          {
            name: "发货数",
            type: 'line',
            itemStyle: {
              color: 'rgb(254, 61, 61)'
            },
            smooth: true,
            
             areaStyle: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                      {
                        offset: 0,
                        color: 'rgba(254, 61, 61, 0.1)'
                      },
                      {
                        offset: 1,
                        color: 'rgba(254, 61, 61, 0)'
                      }
                    ])
                  },
            data: []
          },
          {
            name: "发展订单数",
            type: 'line',
            itemStyle: {
              color: 'rgb(0, 90, 255)'
            },
            smooth: true,
            
            areaStyle: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgba(0, 90, 255,0.9)'
                },
                {
                  offset: 1,
                  color: 'rgba(0, 90, 255,0.1)'
                }
              ])
            },
            data: []
          },
        ]
        this.yizhou.data.forEach(item=>{
          x.push(item.date)
          y[0].data.push(item.deliver_count)
          y[1].data.push(item.orders_count)
        })
        myChart.setOption({
          tooltip: {
              trigger: 'axis'
            },
          legend: {
              left:'30px',
              data: ['发货数','发展订单数']
          },
          xAxis: {
            type: 'category',
            data: x
          },
          yAxis: {
            type: 'value'
          },
          series: y
        });

      },
      end:function(){
        this.$emit('end')
      },
      getlist2:function(){
        console.log(1)
        axios.get('/own/week/count').then((response)=>{
        	if (response.data.msg.code == 0) {
            this.yizhou = response.data.data
            this.qushitu()
        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      }
		}
	}
</script>


<style scoped>

</style>
